<template>
  <div class="header-box">
    <div class="header-gradient"></div>
    <div class="header-content">
      <div class="h-title-left headerbox-item to-bottom" @click="handleLoginOut">
        数字治理平台
      </div>
      <div class="h-right headerbox-item">
        <!-- <div class="full-screen" @click="handleFullScreen" ref="fullScreen">
          <el-icon>
            <FullScreen />
          </el-icon>
        </div> -->
        <div class="h-time">
          <div>{{ currentTime }}</div>
        </div>
        <!-- <div class="h-title">管委会：泰州学院教工管理委会</div> -->
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref } from "vue";
import { ElMessage, ElMessageBox } from "element-plus";
import formatTime from "@/utils/formatTime";
import { useRouter } from "vue-router";
const router = useRouter();

const currentTime = ref(formatTime(new Date()));
setInterval(() => {
  currentTime.value = formatTime(new Date());
}, 1000);

const fullScreen = ref(null);

// 处理登出
const handleLoginOut = () => {
  ElMessageBox.confirm(
    '你确定要退出平台吗',
    'Warning',
    {
      confirmButtonText: '确定',
      cancelButtonText: '取消',
      type: 'warning',
    }
  ).then(() => {
    router.push({ name: 'loginPage' })
  })
}

const handleFullScreen = () => {
  if (!fullScreen.value) {
    return
  }
  fullScreen.value.addEventListener('click', () => {
    if (document.fullscreenElement) {
      document.exitFullscreen();
    } else {
      fullScreen.value.requestFullscreen();
    }
  });
}

</script>

<style scoped>
.header-box {
  width: 100%;
  height: 6.5625vw;
  position: relative;
  color: #fff;
}

/* 添加渐变背景遮罩 */
.header-gradient {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(to bottom,
      rgba(0, 0, 0, 0.9) 0%,
      rgba(0, 0, 0, 0.7) 50%,
      rgba(0, 0, 0, 0) 100%);
  pointer-events: none;
}

/* 包装内容的容器 */
.header-content {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: space-between;
  box-sizing: border-box;
  padding-left: 1.5vw;
  padding-right: 1.5vw;
  align-items: center;
}

.header-content .headerbox-item {
  width: 20vw;
  font-size: 1.25vw;
}

.header-content .h-title {
  font-size: 1vw;
}

.header-content .h-title-left {
  font-size: 1.78vw;
  font-family: homeTime;
  width: 27.9vw;
  height: 2.1vw;
  line-height: 2.1vw;
  letter-spacing: 0.3vw;
  text-align: left;
  white-space: nowrap;
  background: url("../../assets/home/leftTittleLine.png") bottom no-repeat;
  padding-bottom: 0.5vh;
  background-size: 100% 0.5vw;
  flex-basis: 30vw;
  cursor: pointer;
}

.h-right .h-time {
  font-size: 1.25vw;
  font-family: homeTime;
  line-height: 1.25vw;
  color: #fff;
  letter-spacing: 0.15625vw;
  text-shadow: 0 -0.208333vw 0.416667vw #f910c8;
}

.h-right .h-time div {
  text-align: center;
}

.h-right .h-name {
  margin-top: 0.520833vw;
}

.h-right .h-title {
  text-align: right;
  padding-right: 1vw;
  margin-top: 1vh;
}

.h-right .full-screen {
  text-align: right;
  margin-top: -3vh;
}

</style>
